url_list_input = [
 "https://img-a.udemycdn.com/course/240x135/2150122_6aae_3.jpg",
 "http://www.w3big.com/python3/python3.png",
 "http://www.w3big.com/python3/python3.png",
 "https://baidu.com/",
 "https://udemycoupons.me/wp-content/uploads/2019/11/Udemy-Coupons-Comprehensive-Python3-Bootcamp-2020-From-A-to-Expert-100-OFF-696x436.jpg"
]
#

# 这里不支持网络下载所以可以用自己的编辑器完成，我们会再做代码验证
import threading,requests,io
# 'Content-Type'
img_type_list = ['image/png','image/jpeg']

# total_size = 0
# lock = threading.Lock()
# def get_img_size(url):
#     global total_size
#     res = requests.get(url)
#     img_type = res.headers.get('Content-Type')
#     if img_type in img_type_list:
#         size = res.headers.get('Content-Length')
#         if not size:
#             image = res.content
#             image_b = io.BytesIO(image).read()
#             size = len(image_b)
#         lock.acquire()
#         total_size += int(size)
#         lock.release()
d = {}
def get_img_size(url):
    res = requests.get(url)
    img_type = res.headers.get('Content-Type')
    if img_type in img_type_list:
        size = res.headers.get('Content-Length')
        if not size:
            image = res.content
            image_b = io.BytesIO(image).read()
            size = len(image_b)
        d[url] = int(size)

def mt_remote_image_size(url_list_input):
    added = set()
    for i in url_list_input:
        if i not in added:
            added.add(i)
            t = threading.Thread(target=get_img_size,args=(i,))
            t.start()
            t.join()
    print(d.values())

mt_remote_image_size(url_list_input)